<include file="../Public/_header" />
<div class="so_main">
<script>
function sureSearchDenounce(){
	var id = $('#id').val();
	var uid = $('#uid').val();
	var fuid = $('#fuid').val();
	var from = $('#from').val();
	var state = $('#state').val();
	var str_get = '&id='+id+'&uid='+uid+'&fuid='+fuid+'&from='+from+'&state='+state;
	var url = "{:U('admin/Content/denounce')}";
	location.href = url + str_get;
}
</script>
  <div class="page_tit">举报管理</div>
  <div class="tit_tab">
    <ul>
    <li><a <eq name="state" value="0">class="on"</eq> href="{:U('admin/Content/denounce','state=0')}">等待操作</a></li>
    <li><a <eq name="state" value="1">class="on"</eq> href="{:U('admin/Content/denounce','state=1')}">回收站</a></li>
    <li><a <eq name="state" value="2">class="on"</eq> href="{:U('admin/Content/denounce','state=2')}">审核通过</a></li>
    </ul>
  </div>
  <div id="search_div" <neq name="isSearch" value="1">style="display:none;"</neq>>
    <div class="page_tit">搜索举报 [ <a href="javascript:void(0);" onclick="searchDenounce();">隐藏</a> ]</div>
    <div class="form2">
    <input type="hidden" name="isSearch" value="1"/>
    <dl class="lineD">
      <dt>ID：</dt>
      <dd>
        <input id="id" type="text" value="{$id}">
        <p>多个时使用英文的“,”分割</p>
      </dd>
    </dl>
    
    <php>if($isSearch != 1) $uid = '';</php>
    <dl class="lineD">
      <dt>举报人ID：</dt>
      <dd>
        <input id="uid" type="text" value="{$uid}">
        <p>举报人ID,多个时使用英文的","分割</p>
      </dd>
    </dl>
    
    <dl class="lineD">
      <dt>被举报人：</dt>
      <dd>
      	<input type="text" id="fuid" value="{$fuid}" />
      </dd>
    </dl>
    
    <dl class="lineD">
      <dt>来自：</dt>
      <dd>
      	<input type="text" id="from" value="{$from}" />
      </dd>
    </dl>
    
    <dl class="lineD">
      <dt>类型：</dt>
      <dd>
      	<select id="state">
      		<option value="0">等待操作</option>
      		<option value="1">回收站</option>
      		<option value="2">通过审核</option>
      	</select>
      </dd>
    </dl>
    <div class="page_btm">
      <input type="submit" class="btn_b" value="确定" onclick="sureSearchDenounce();"/>
    </div>
  </div>
  </div>
  <div class="Toolbar_inbox">
    <div class="page right">{$html}</div>
    <a href="javascript:void(0);" class="btn_a" onclick="searchDenounce();">
        <span class="search_action"><neq name="isSearch" value="1">搜索举报<else/>搜索完毕</neq></span>
    </a>
    <a href="javascript:void(0);" class="btn_a" onclick="passReview();"><span>通过审核</span></a>
    <a href="javascript:void(0);" class="btn_a" onclick="deleteRecord();"><span>进入回收站</span></a>
  </div>
  <div class="list">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th style="width:30px;">
        <input type="checkbox" id="checkbox_handle" onclick="checkAll(this)" value="0">
        <label for="checkbox"></label>
    </th>
    <th class="line_l">ID</th>
    <th class="line_l">举报人ID</th>
    <th class="line_l">举报人用户名</th>
    <th class="line_l">来自</th>
    <th class="line_l">被举报信息</th>
    <th class="line_l">举报理由</th>
    <th class="line_l">举报时间</th>
    <th class="line_l">操作</th>
  </tr>
  <volist id="vo" name="data">
      <tr overstyle='on' id="Denounce_{$vo.id}">
        <td><input type="checkbox" name="checkbox" id="checkbox2" onclick="checkon(this)" value="{$vo.id}"></td>
        <td>{$vo.id}</td>
        <td>{$vo.uid}</td>
        <td><php> if( $vo['uid']=='0' ){ echo '<font color=red>系统自动</font>'; }else{ echo getUserName( $vo['uid'] ); } </php></td>
        <td>{$vo.from}</td>
        <td>被举报人UID：{$vo.fuid}&nbsp;&nbsp;&nbsp;&nbsp;被举报人用户名：{$vo.fuid|getUserName}<hr />被举报内容前140字：{$vo.content}</td>
        <td>{$vo.reason}</td>
        <td>{$vo.ctime|date="Y-m-d H:i:s",###}</td>
        <td>
        <eq name="state" value="0">
	        <a href="javascript:void(0);" onclick="passReview('{$vo.id}');">通过审核</a>&nbsp;&nbsp;|&nbsp;&nbsp;
	        <a href="javascript:void(0);" onclick="deleteRecord('{$vo.id}')">进入回收站</a>
	    </eq>
	    <eq name="state" value="1">
	        <a href="javascript:void(0);" onclick="passReview('{$vo.id}');">通过审核</a>
	    </eq>
	    <eq name="state" value="2">
	        <a href="javascript:void(0);" onclick="deleteRecord('{$vo.id}')">进入回收站</a>
	    </eq>
        </td>
      </tr>
  </volist>
  </table>
  </div>
  <div class="Toolbar_inbox">
    <div class="page right">{$html}</div>
    <a href="javascript:void(0);" class="btn_a" onclick="searchDenounce();">
        <span class="search_action"><neq name="isSearch" value="1">搜索举报<else/>搜索完毕</neq></span>
    </a>
    <a href="javascript:void(0);" class="btn_a" onclick="passReview();"><span>通过审核</span></a>
    <a href="javascript:void(0);" class="btn_a" onclick="deleteRecord();"><span>进入回收站</span></a>
  </div>
</div>

<script>
    //鼠标移动表格效果
    $(document).ready(function(){
        $("tr[overstyle='on']").hover(
          function () {
            $(this).addClass("bg_hover");
          },
          function () {
            $(this).removeClass("bg_hover");
          }
        );
    });
    
    function checkon(o){
        if( o.checked == true ){
            $(o).parents('tr').addClass('bg_on') ;
        }else{
            $(o).parents('tr').removeClass('bg_on') ;
        }
    }
    
    function checkAll(o){
        if( o.checked == true ){
            $('input[name="checkbox"]').attr('checked','true');
            $('tr[overstyle="on"]').addClass("bg_on");
        }else{
            $('input[name="checkbox"]').removeAttr('checked');
            $('tr[overstyle="on"]').removeClass("bg_on");
        }
    }

    //获取已选择用户的ID数组
    function getChecked() {
        var ids = new Array();
        $.each($('table input:checked'), function(i, n){
            ids.push( $(n).val() );
        });
        return ids;
    }
    
    function deleteRecord(ids) {
        var length = 0;
    	if(ids) {
    		length = 1;    		
    	}else {
    		ids    = getChecked();
    		length = ids.length;
            ids    = ids.toString();
    	}
    	
    	if(ids=='') {
    		ui.error('请先选择一个举报');
    		return ;
    	}
    	if(confirm('您将删除'+length+'条记录，确定继续？')) {
    		$.post("{:U('admin/Content/doDeleteDenounce')}",{ids:ids},function(res){
    			if(res=='1') {
    				ui.success('删除成功');
    				removeItem(ids);
    			}else {
    				ui.error('删除失败');
    			}
    		});
    	}
    }
    
    function passReview(ids){
    	var length = 0;
    	if(ids) {
    		length = 1;    		
    	}else {
    		ids    = getChecked();
    		length = ids.length;
            ids    = ids.toString();
    	}
    	
    	if(ids=='') {
    		ui.error('请先选择一个举报');
    		return ;
    	}
    	if(confirm('您将审核通过'+length+'条记录，确定继续？')) {
    		$.post("{:U('admin/Content/doReviewDenounce')}",{ids:ids},function(res){
    			if(res=='1') {
    				ui.success('审核成功');
    				removeItem(ids);
    			}else {
    				ui.error('审核失败');
    			}
    		});
    	}
    }
    
    function removeItem(ids) {
    	ids = ids.split(',');
        for(i = 0; i < ids.length; i++) {
            $('#Denounce_'+ids[i]).remove();
        }
    }
    
    //搜索用户
    var isSearchHidden = <neq name="isSearch" value="1">1<else/>0</neq>;
    function searchDenounce() {
        if(isSearchHidden == 1) {
            $("#search_div").slideDown("fast");
            $(".search_action").html("搜索完毕");
            isSearchHidden = 0;
        }else {
            $("#search_div").slideUp("fast");
            $(".search_action").html("搜索举报");
            isSearchHidden = 1;
        }
    }
</script>

<include file="../Public/_footer" />